package com.yanqu.road.server.cmd.wineshop;

import com.yanqu.road.pb.wineshop.WineShopProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.manger.config.WineShopMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;

/**
 * @author ：zfr
 * @date ：2021/7/21 9:36
 */
@Cmd(code = GameProtocol.S_WINESHOP_CROSS_VISIT, desc = "酒肆跨服来拜访")
public class WineShopCrossVisitCmd implements Command {
    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        WineShopProto.CrossVisitOtherWineShopReqMsg msg = WineShopProto.CrossVisitOtherWineShopReqMsg.parseFrom(packet.getBytes());
        WineShopProto.CrossVisitOtherWineShopRespMsg.Builder respMsg = WineShopProto.CrossVisitOtherWineShopRespMsg.newBuilder();
        respMsg.setMsg(WineShopMgr.visitWineShop(msg.getVisitPlayerId()));
        respMsg.setOriginPlayerId(msg.getOriginPlayerId());
        respMsg.setOriginServerId(msg.getOriginServerId());
        YanQuMessage message = YanQuMessageUtils.buildMessage(CrossProtocol.C_CROSS_VISIT_PLAYER_WINESHOP_RESP, respMsg);
        GamePlayerMgr.sendPacket(0, message);
    }
}
